#ifndef WIDGET_H
#define WIDGET_H

#include <QCheckBox>
#include <QPushButton>
#include <QSerialPort>
#include <QTimer>
#include <QWidget>
#include "mycombobox.h"
#include "customthread.h"

QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACE

class Widget : public QWidget
{
    Q_OBJECT

public:
    Widget(QWidget *parent = nullptr);
    ~Widget();

private slots:
    void on_btnCtrlSerial_clicked();

    void on_btnSendContext_clicked();

    void on_SerialData_ReadyToRead();

    void on_checkBoxSendinTime_clicked(bool checked);

    void on_btnRevClear_clicked();

    void on_btnRevSave_clicked();

    void time_reflash();

    void on_checkBHexDisplay_clicked(bool checked);

    void on_btnHideTable_clicked(bool checked);

    void on_btnHideHistory_clicked(bool checked);

    void refreshSerialName();

    void on_command_button_clicked();
    void on_checkBox_send_clicked(bool checked);

    void buttons_handler();

    void on_btnInit_clicked();

    void on_btnSave_clicked();

    void on_btnLoad_clicked();

private:
    Ui::Widget *ui;
    QSerialPort  *serialport;
    //记录总发送数据
    int writeCntTotal;
    //记录总收到数据
    int readCntTotal;
    //用于防止重复字符串位于历史记录
    QString sendBak;
    //用于控制打开或关闭串口按键
    bool serialStatus;
    QTimer *timer;
    QString myTime;
    QTimer *getSysTimeTimer;
    int buttonIndex;//控制多文本循环定时发送时下标位置
    QTimer* buttonsConTimer;
    CustomThread *mythread;
    void getSysTime();

    QList<QPushButton*> buttons;
    QList<QLineEdit *>lineEdits;
    QList<QCheckBox *>checkBoxs;
};
#endif // WIDGET_H
